package com.packet.cheng.exception;

import com.packet.cheng.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 @author zaicheng
 @version 1.0
 @date 2022-04-19
 @email zzc15847256473@163.com

 全局异常处理器
 */
//@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {


    @Resource
    private HttpServletRequest  request;

    /*@ExceptionHandler()
    public R<Map<String,String>>   handleParameterException(){

    }*/

    //@ExceptionHandler(Exception.class)
    public R<Map<String,String>>   handleException(Exception e){
        log.error("异常消息："+e);
        String requestURI = request.getRequestURI();
        R<Map<String,String>>  r=R.error();
        return  r;
    }

}
